package com.yichi;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.yichi.device_bean.BatteryStore;
import com.yichi.device_bean.PlcInfo;
import com.yichi.service.PlatformService;
import com.yichi.service.PlcService;
import com.yichi.util.BeanUtil;

public class QuDianTipFragment extends Fragment {

    private final static String TAG = "QuDianTipFragment";

    private TextView tip1, tip2;
    private String str1, str2;
    int i;

    public QuDianTipFragment() {

    }

    public QuDianTipFragment(String str1, String str2) {
        this.str1 = str1;
        this.str2 = str2;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fg_qudian, container, false);
        findView(view);
        tip1.setText(this.str1);
        tip2.setText(this.str2);
//        setView();
        return view;
    }

    private void setView() {
        tip2.setOnClickListener(view -> {
            int index = i % 4;
            switch (index) {
                case 0:
                    tip1.setText("用户张**的订单进行中");
                    tip2.setText("仓门已开，请取电，取出后\n请关闭仓门");
                    break;
                case 1:
                    tip1.setText("用户张**正在存电，请按照提示操作");
                    tip2.setText("正在开门请稍等\n请留意仓门");
                    break;
                case 2:
                    tip1.setText("用户张**正在取电，请按照提示操作");
                    tip2.setText("电池已取走\n请关闭仓门");
                    break;
                case 3:
                    tip1.setText("用户张**正在取电，请按照提示操作");
                    tip2.setText("仓门已开，请存电\n存入后请关闭仓门");
                    break;

            }
            i++;
        });
    }

    private void findView(View view) {
        tip1 = view.findViewById(R.id.tip1);
        tip2 = view.findViewById(R.id.tip2);
    }
}
